package com.shujia.day14;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;

public class Code01FileOutputStream {
    public static void main(String[] args) throws IOException {

        FileOutputStream fileOutputStream = new FileOutputStream(new File("data/d.txt"), true);

        fileOutputStream.write("abc".getBytes());
        fileOutputStream.write("今天天气真好呀".getBytes());

        // 关闭流
        fileOutputStream.close();


        FileOutputStream fileOutputStream1 = new FileOutputStream("data/e.txt");

        System.out.println(Arrays.toString("张东东真帅呀".getBytes()));
//        fileOutputStream1.write("张东东真帅呀".getBytes(),1,4);  // 对于中文的字符串来说，每个字符由UTF8编码转成字节后 会产生3个字节 所以在做字节数组截取时要注意长度
        fileOutputStream1.write("张东东真帅呀".getBytes());
        fileOutputStream1.close();


    }
}
